package track_code;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.RandomStringUtils;

/**
 * Created by IntelliJ IDEA.
 * User: ciano
 * Date: 14-12-7
 * Time: 上午10:45
 * To change this template use File | Settings | File Templates.
 */
public class PasswordUtil {
    public static String md5Encode(String rawpassword) {
        byte[] encoded = Base64.encodeBase64(DigestUtils.md5(rawpassword));
        return new String(encoded);
    }

    public static String randomPassword() {
        return RandomStringUtils.randomNumeric(6);
    }

    public static String randomShopNo() {
        return RandomStringUtils.randomAlphanumeric(12);
    }

    public static String randomSmsCode() {
        return RandomStringUtils.randomNumeric(6);
    }

    private static double rad(double d) {
        return d * Math.PI / 180.0;
    }
}
